<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户授权</title>
<link rel="stylesheet" type="text/css"
	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"
	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"
	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"
	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="../../static/js/themes/icon.css">
<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<%
	String f_role_ids = request.getParameter("f_role_ids");
	String f_role_names = request.getParameter("f_role_names");
	String f_pour_roleIds = request.getParameter("f_pour_roleIds");
%>
<script type="text/javascript">
	var f_role_ids = "<%=f_role_ids%>";
	var f_role_names = decodeURIComponent("<%=f_role_names%>");
	var f_pour_roleIds = decodeURIComponent("<%=f_pour_roleIds%>");
	var idArr = [];
	var nameArr = [];
	var f_pour_roleIdsArr = [];
	$(function(){
		$("#authorizeList").empty();
		if(f_pour_roleIds.indexOf(",")!=-1){
			f_pour_roleIdsArr = f_pour_roleIds.split(',');
		}

		if(f_role_ids.indexOf(",")!=-1){
			idArr = f_role_ids.split(',');
			nameArr = f_role_names.split(',');
			var str="";
			for(var i=0;i<idArr.length-1;i++){
				var roleIsExist = false;
				for(var j=0;j<f_pour_roleIdsArr.length;j++) {
					if(idArr[i]== f_pour_roleIdsArr[j]){
						roleIsExist = true;
					}
				}
				if(roleIsExist){
					str+='<input name="sample-check" value="'+idArr[i]+'" type="checkbox" checked="checked" >'+nameArr[i]+'</input></br>';
				}else{
					str+='<input name="sample-check" value="'+idArr[i]+'" type="checkbox" >'+nameArr[i]+'</input></br>';
				}
			}
			$("#authorizeList").append(str);
		}
	});
	
	function _submitFm() {
		//获取选中的值
		var userRoleList = "";
		var userRoleNameList = "";
		var i=0;
		$.each($('input:checkbox'),function(){
            if(this.checked){
            	userRoleList+=$(this).val()+",";
    			userRoleNameList +=nameArr[i]+",";
            }
            i++;
        });
		window.parent.document.getElementById("f_pour_roleNames").value=userRoleNameList.substring(0,userRoleNameList.length-1);
		window.parent.document.getElementById("f_pour_roleIds").value=userRoleList;
		parent.$('#dlg').dialog('close');
	}
</script>
</head>

<body class="overfwidth">
	<div class="barnavtop">您所在的位置：用户管理 &gt; 用户授权</div>
	<div id="workspace">
		<!--主体 开始-->
		<div id="container">
			<div class="editspace">
				<form id="contentForm" class="cmxform" enctype="multipart/form-data"
					name="formName">
					<legend>用户授权</legend>
					<fieldset>

					<fieldset>
						<div id="authorizeList" class="fitem">
							
						</div>
					</fieldset>

				</form>
			</div>
			<div class="toolbar" style="text-align: center;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
					href="javascript:void(0);" onclick="_submitFm()">保存</a> <a
					href="javascript:void(0);" data-options="iconCls:'icon-cancel'"
					class="easyui-linkbutton"
					onclick="javascript:parent.$('#dlg').dialog('close')">取消</a>
			</div>
		</div>
		<!--主体 结束-->
	</div>
</html>
